<template>
  <transition name="fade">
    <div class="login-popup" v-show="show">
      <div class="popup">
        <h2>提示</h2>
        <p>{{content}}</p>
        <div class="buttons text-right">
          <button class="button button-stable button-outline" @click="cancel" v-if="!alertFlag">取消</button>
          <button class="button button-energized" @click="ensure">确定</button>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  props: {
    value: {
      type: Boolean,
      default: false
    },
    alertFlag: {
      type: Boolean,
      default: false
    },
    content: {
      type: String
    }
  },
  computed: {
    show () {
      return this.value
    }
  },
  methods: {
    ensure () {
      this.$emit('ensure')
    },
    cancel () {
      this.$emit('input', false)
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped lang="scss">
.login-popup {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 10001;
  .popup {
    position: fixed;
    width: 400px;
    background: $light;
    left: 50%;
    margin-left: -200px;
    top: 30%;
    padding: 15px;
    border-radius: 6px;
    h2 {
      font-weight: normal;
    }
    p {
      padding: 30px 0;
    }
    .buttons {
      .button {
        margin-left: 15px;
      }
    }
  }
}
</style>
